<template>
  <div>
    <FormPanel ref="formPanel" :list="formList" :formType="type" @formChange="changeHandle" :isSubmitBtn="false" :collapse="false" labelWidth="110" />
    <FormPanel ref="formPanel1" :list="formList1" :formType="type" @formChange="changeHandle1" :isSubmitBtn="false" :collapse="false" labelWidth="110" />
    <FormPanel ref="formPanel2" :list="formList2" :formType="type" @formChange="changeHandle2" :isSubmitBtn="false" :collapse="false" labelWidth="110" />
    <div style="height:47px;"></div>
    <div
      :style="{
        position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'center'
      }"
    >
      <multiuse-button type="primary" v-show="type != 'show'" :disabled="!isCan" :click="saveOrCommitHandle.bind(this, 60521002)">提 报</multiuse-button>
      <multiuse-button type="primary" v-show="type != 'show'" :click="saveOrCommitHandle.bind(this, 60521001)">保 存</multiuse-button>
      <el-button @click="closeDrawer">关 闭</el-button>
    </div>

    <BaseDialog :visible.sync="isShowCstmr" :title="'潜客信息'" destroyOnClose :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }">
      <SearchCstmr :rowData="formData" @close="closeDialog" />
    </BaseDialog>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { getEmployees, saveReport, orderReportDataById, commitReportByDto } from '@/api/dealerSale/SalesSanagement/ActualSalesReport';
import { banWord, numberCheck, IDNumber, checkPassport, CheckSocialCreditCode } from '@/utils/validate';
import { phoneAndSolidify, telePhone, phone } from '@/utils/validate.js';
import SearchCstmr from './SearchCstmr';

export default {
  mixins: [dictionary],
  props: ['type', 'rowData'],
  components: {
    SearchCstmr
  },

  data() {
    this.saveData = null;
    this.saveData1 = null;
    this.saveData2 = null;
    return {
      formList: this.createdFrom(),
      formList1: this.createdFrom1(),
      formList2: this.createdFrom2(),
      formData: {},
      isShowCstmr: false,
      isCan: false,
      empList: [],
      carInfo: {},
      customerInfo: {},
      salesReportInfo: {}
    };
  },
  mounted() {
    this.init();
    // this.queryEmployees();
  },
  methods: {
    init() {
      if (this.type != 'add') {
        this.getInfoById();
      }

      if (this.type == 'show') {
        this.formList.map(x => {
          x.placeholder = '';
          if (x.rules) {
            x.rules[0].required = false;
          }
        });
        this.formList1.map(x => {
          x.placeholder = '';
          if (x.rules) {
            x.rules[0].required = false;
          }
        });
        this.formList2.map(x => {
          x.placeholder = '';
          if (x.rules) {
            x.rules[0].required = false;
          }
        });
      }
    },
    // 查询销售顾问
    async queryEmployees() {
      const res = await getEmployees();
      if (res.resultCode == 200) {
        res.data.map(x => {
          this.empList.push({ text: x.userName, value: x.userId });
          this.formList2.find(item => item.fieldName == 'salesManId').itemList.push({ text: x.userName, value: x.userId });
        });
      }
    },
    // 查询潜客
    cstmrNoHandle() {
      this.isShowCstmr = true;
    },
    closeDialog(val, data) {
      this.isShowCstmr = val;
      this.cstmrData = data[0];
      this.setFormData(data[0]);

      console.log(data, '---关闭潜客---');
    },
    setFormData(data) {
      for (let key in data) {
        this.formList1.map(x => {
          if (x.fieldName == 'customerNo') {
            x.initialValue = data['potentialCustomerNo'];
          }
          if (x.fieldName == 'customerName') {
            x.initialValue = data['customerName'];
          }
          if (x.fieldName == 'customerPhone') {
            x.initialValue = data['mobilePhone'];
          }
          if (x.fieldName == 'cardType') {
            x.initialValue = data['ctCode'];
            this.changeCardType(data['ctCode']);
          }
          if (x.fieldName == 'cardNo') {
            x.initialValue = data['certificateNo'];
          }
          if (x.fieldName == 'provinceId') {
            x.initialValue = data['province'] ? Number(data['province']) : '';
          }
          if (x.fieldName == 'cityId') {
            x.initialValue = data['city'] ? Number(data['city']) : '';
            x.itemList = this.createcityList(data.province);
          }
          if (x.fieldName == 'districtId') {
            x.initialValue = data['area'] ? Number(data['area']) : '';
            x.itemList = this.district(data.city);
          }
          if (x.fieldName == 'linkAddress') {
            x.initialValue = data['address'];
          }
        });
      }
    },
    // 详细
    async getInfoById() {
      const res = await orderReportDataById(this.rowData.orderId);
      if (res.resultCode == 200) {
        if (res.data.vsSalesReportDTO) this.isCan = true;
        // 车辆信息
        this.carInfo = res.data.orderVinShowDto || {};
        // 客户信息
        this.customerInfo = res.data.vsCustomerDTO || {};
        this.formList1.find(x => x.fieldName == 'cityId').itemList = this.createcityList(this.customerInfo.provinceId);
        this.formList1.find(x => x.fieldName == 'districtId').itemList = this.district(this.customerInfo.cityId);
        // 销售信息
        this.salesReportInfo = res.data.vsSalesReportDTO != null ? res.data.vsSalesReportDTO : JSON.parse(JSON.stringify(res.data));
        this.formList2.find(x => x.fieldName == 'plateCity').itemList = this.createcityList(this.salesReportInfo.plateProvince);

        this.formList.forEach(x => {
          x.initialValue = this.carInfo[x.fieldName];
        });
        this.formList1.forEach(x => {
          if (x.fieldName == 'customerLevel') {
            if (this.customerInfo['reportStatus'] && this.customerInfo['reportStatus'] == 60521003) {
              x.initialValue = 15191004;
              return;
            }
            x.initialValue = 15191008;
          } else if (x.fieldName == 'customerType') {
            Object.keys(this.customerInfo).length != 0 ? this.showItems1(this.customerInfo['customerType']) : '';
          } else {
            x.initialValue = this.customerInfo[x.fieldName];
            this.changeCardType(this.customerInfo['cardType']);
          }
        });
        this.formList2.forEach(x => {
          if (x.fieldName == 'deliveryDate') {
            x.initialValue = this.salesReportInfo['deliveryDate'] || res.data['stockOutData'];
          } else if (x.fieldName == 'payType') {
            Object.keys(this.salesReportInfo).length != 0 ? this.showItems2(this.salesReportInfo['payType']) : '';
          } else if (x.fieldName == 'buyPrice') {
            console.log(this.salesReportInfo, '---奥利给---');
            x.initialValue = res.data.vsSalesReportDTO != null ? this.salesReportInfo['buyPrice'] : this.salesReportInfo['salesQuatation'];
          } else if (x.fieldName == 'invoiceUrls') {
            if (this.carInfo.powerType == '60081002' && this.type != 'show') {
              x.rules[0].required = true;
            }
            x.initialValue = this.salesReportInfo['invoiceUrls'];
          } else {
            x.initialValue = this.salesReportInfo[x.fieldName];
          }
        });
      }
    },
    showItems1(type) {
      this.formList1.find(x => x.fieldName == 'customerType').initialValue = type;
      if (type == 15231003) {
        this.formList1.find(x => x.fieldName == 'companyLinkMan').hidden = false;
        this.formList1.find(x => x.fieldName == 'companyLinkPhone').hidden = false;
        this.formList1.find(x => x.fieldName == 'corpName').hidden = false;
        this.formList1.find(x => x.fieldName == 'corpMobile').hidden = false;
        this.formList1.find(x => x.fieldName == 'fax').hidden = false;
        return;
      }
      this.formList1.find(x => x.fieldName == 'companyLinkMan').hidden = true;
      this.formList1.find(x => x.fieldName == 'companyLinkPhone').hidden = true;
      this.formList1.find(x => x.fieldName == 'corpName').hidden = true;
      this.formList1.find(x => x.fieldName == 'corpMobile').hidden = true;
      this.formList1.find(x => x.fieldName == 'fax').hidden = true;
    },
    showItems2(type) {
      this.formList2.find(x => x.fieldName == 'payType').initialValue = type;
      if (type == 60151001) {
        this.formList2.find(x => x.fieldName == 'financialInstitution').hidden = false;
        this.formList2.find(x => x.fieldName == 'periodsNumber').hidden = false;
        return;
      }
      this.formList2.find(x => x.fieldName == 'financialInstitution').hidden = true;
      this.formList2.find(x => x.fieldName == 'periodsNumber').hidden = true;
    },
    changeHandle(val) {
      this.saveData = val;
    },
    changeHandle1(val) {
      this.saveData1 = val;
    },
    changeHandle2(val) {
      this.saveData2 = val;
    },
    async saveOrCommitHandle(type) {
      this.$refs.formPanel.SUBMIT_FORM();
      this.$refs.formPanel1.SUBMIT_FORM();
      this.$refs.formPanel2.SUBMIT_FORM();

      if (this.saveData != null && this.saveData1 != null && this.saveData2 != null) {
        // 客户信息 省市区 获取name
        this.saveData1.provinceName = this.transDictText(this.saveData1.provinceId, this.createRegionsList());
        this.saveData1.cityName = this.transDictText(this.saveData1.cityId, this.createcityList(this.saveData1.provinceId));
        this.saveData1.districtName = this.transDictText(this.saveData1.districtId, this.district(this.saveData1.cityId));
        // 实销信息 获取上牌 省市
        // this.saveData2.salesManName = this.transDictText(this.saveData2.salesManId, this.empList);
        this.saveData2.plateProvinceName = this.transDictText(this.saveData2.plateProvince, this.createRegionsList());
        this.saveData2.plateCityName = this.transDictText(this.saveData2.plateCity, this.createcityList(this.saveData2.plateProvince));
        let infoData = {
          orderVinShowDto: Object.assign(this.carInfo, this.saveData),
          vsCustomerDTO: Object.assign(this.customerInfo, this.saveData1),
          vsSalesReportDTO: Object.assign(this.salesReportInfo, this.saveData2)
        };
        let saveData = Object.assign(this.rowData, JSON.parse(JSON.stringify(infoData)));

        let res = {};
        if (type == 60521002) {
          // 提报
          res = await commitReportByDto(saveData);
        }
        if (type == 60521001) {
          // 保存
          res = await saveReport(saveData);
        }
        if (res.resultCode == 200) {
          this.$notify.success({ title: '提示信息', message: type == 60521001 ? '保存成功' : '提报成功' });
          this.closeDrawer('refresh');
        }
      }
    },
    closeDrawer(type) {
      this.$emit('close', false, type);
    },
    // 翻译省市区
    transDictText(val, dirtArr) {
      console.log(dirtArr, '---翻译---');
      let res = '';
      if (!val) return res;
      if (Array.isArray(dirtArr)) {
        const target = dirtArr.find(x => x.value == val);
        res = target ? target.text || '' : val;
      }
      return res;
    },

    //改变证件类型,证件类型为身份证的时候加校验
    changeCardType(val) {
      if (15081001 == val) {
        this.formList1.find(item => item.fieldName === 'cardNo').rules = [
          { required: true, trigger: 'blur', message: '请输入证件号码' },
          { trigger: 'blur', validator: IDNumber }
        ];
        return;
      }
      this.formList1.find(item => item.fieldName === 'cardNo').rules = [
        { required: true, message: '请输入证件号码', trigger: 'blur' },
        { trigger: 'blur', validator: banWord }
      ];
    },
    // ---------------------------车辆信息---------------------------
    createdFrom() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '车辆信息'
        },
        {
          type: 'INPUT',
          label: '车系名称',
          fieldName: 'seriesName',
          initialValue: '',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '车型名称',
          fieldName: 'modelName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '配置名称',
          fieldName: 'packageName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '选装名称',
          fieldName: 'optionName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '内饰',
          fieldName: 'trimColorName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '外色',
          fieldName: 'colorName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '产品代码',
          fieldName: 'productCode',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '产品名称',
          fieldName: 'productName',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '销售指导价',
          fieldName: 'basicPrice',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: 'VIN号',
          fieldName: 'vin',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '发动机号',
          fieldName: 'engineNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '电机号',
          fieldName: 'motorCode',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '合格证号',
          fieldName: 'certificateNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '电池号',
          fieldName: 'batteryNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'DATE',
          label: '配车日期',
          fieldName: 'distributionDate',
          dateType: 'exactdate',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '公告号',
          fieldName: 'noticeNo',
          placeholder: '',
          disabled: true
        },
        {
          type: 'DATE',
          label: '出库日期',
          fieldName: 'stockOutData',
          dateType: 'exactdate',
          offsetLeftCols: 1,
          placeholder: '',
          disabled: true
        }
      ];
    },
    // ----------------------------客户信息--------------------------
    createdFrom1() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '客户信息'
        },
        {
          type: 'INPUT',
          label: '零售单号',
          fieldName: 'retailOrderNo',
          placeholder: '选择或者带入',
          // rules: [{ required: true, message: '请输入', trigger: 'blur' }],
          disabled: true
        },
        {
          type: 'INPUT',
          label: '客户编号',
          fieldName: 'potentialCustomerNo',
          placeholder: '请输入',
          // readonly: true,
          disabled: true,
          unitRender: () => {
            return <el-button slot="append" icon="el-icon-search" onClick={() => this.cstmrNoHandle()}></el-button>;
          }
        },
        {
          type: 'INPUT',
          label: '客户姓名',
          fieldName: 'customerName',
          placeholder: ''
        },
        {
          type: 'SELECT',
          label: '客户类型',
          fieldName: 'customerType',
          placeholder: '请选择',
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          itemList: this.createDictList('1523'),
          change: val => {
            if (val) {
              this.showItems1(val);
            }
          }
        },
        {
          type: 'SELECT',
          label: '性别',
          fieldName: 'customerSex',
          placeholder: '请选择',
          itemList: this.createDictList('1002'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'DATE',
          label: '出生日期',
          fieldName: 'birthday',
          dateType: 'exactdate',
          placeholder: '请输入'
        },
        {
          type: 'SELECT',
          label: '年龄',
          fieldName: 'age',
          placeholder: '请选择',
          itemList: this.createDictList('9407')
        },
        {
          type: 'INPUT',
          label: '手机号',
          fieldName: 'mobile',
          maxlength: 11,
          placeholder: '请输入',
          rules: [
            { required: true, message: '请输入', trigger: 'blur' },
            {
              validator: phone,
              trigger: 'blur'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '电话',
          maxlength: 11,
          fieldName: 'phone',
          placeholder: '请输入',
          rules: [
            {
              validator: telePhone,
              trigger: 'blur'
            }
          ]
        },

        {
          type: 'SELECT',
          label: '证件类型',
          fieldName: 'cardType',
          placeholder: '请选择',
          itemList: this.createDictList('1508'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          change: val => {
            if (val) {
              this.changeCardType(val);
            }
          }
        },
        {
          type: 'INPUT',
          label: '证件号',
          fieldName: 'cardNo',
          placeholder: '请输入',
          rules: [
            { required: true, message: '请输入证件号码', trigger: 'blur' },
            { trigger: 'blur', validator: banWord }
          ]
        },
        {
          type: 'INPUT',
          label: '微信号',
          fieldName: 'wechatNo',
          placeholder: '请输入'
        },
        {
          type: 'SELECT',
          label: '省份',
          fieldName: 'provinceId',
          placeholder: '请选择',
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          itemList: this.createRegionsList(),
          change: p => {
            if (p) {
              this.formList1.map(x => {
                if (x.fieldName == 'cityId') {
                  x.initialValue = '';
                  x.itemList = this.createcityList(p);
                }
              });
            } else {
              this.formList1.map(x => {
                if (x.fieldName == 'cityId') {
                  x.itemList = [];
                  x.initialValue = '';
                }
                if (x.fieldName == 'districtId') {
                  x.itemList = [];
                  x.initialValue = '';
                }
              });
            }
          }
        },
        {
          type: 'SELECT',
          label: '城市',
          fieldName: 'cityId',
          placeholder: '请选择',
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          itemList: [],
          change: p => {
            if (p) {
              this.formList1.map(x => {
                if (x.fieldName == 'districtId') {
                  x.initialValue = '';
                  x.itemList = this.district(p);
                }
              });
            } else {
              this.formList1.map(x => {
                if (x.fieldName == 'districtId') {
                  x.itemList = [];
                  x.initialValue = '';
                }
              });
            }
          }
        },
        {
          type: 'SELECT',
          label: '县区',
          fieldName: 'districtId',
          placeholder: '请选择',
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          itemList: []
        },
        {
          type: 'INPUT',
          label: '联系地址',
          fieldName: 'linkAddress',
          placeholder: '请输入',
          selfCols: 2,
          rules: [{ required: true, message: '请输入', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '运营单位联系人',
          fieldName: 'companyLinkMan',
          placeholder: '请输入',
          hidden: true
        },
        {
          type: 'INPUT',
          label: '运营单位联系电话',
          fieldName: 'companyLinkPhone',
          placeholder: '请输入',
          hidden: true,
          rules: [
            {
              validator: phoneAndSolidify,
              trigger: 'blur'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '法人代表姓名',
          fieldName: 'corpName',
          placeholder: '请输入',
          hidden: true
        },
        {
          type: 'INPUT',
          label: '法人代表手机',
          maxlength: 11,
          fieldName: 'corpMobile',
          placeholder: '请输入',
          hidden: true,
          rules: [
            {
              validator: phone,
              trigger: 'blur'
            }
          ]
        },
        {
          type: 'INPUT',
          label: '传真',
          fieldName: 'fax',
          placeholder: '请输入',
          hidden: true
        },
        {
          type: 'INPUT_NUMBER',
          label: '邮编',
          fieldName: 'zipCode',
          min: null,
          maxlength: 6,
          placeholder: '请输入'
        },
        {
          type: 'SELECT',
          label: '职业',
          fieldName: 'occupation',
          placeholder: '请选择',
          itemList: this.createDictList('1527')
        },
        {
          type: 'SELECT',
          label: '学历',
          fieldName: 'education',
          placeholder: '请选择',
          itemList: this.createDictList('4049')
        },
        {
          type: 'SELECT',
          label: '户口类型',
          fieldName: 'residenceType',
          placeholder: '请选择',
          itemList: this.createDictList('7062')
        },
        {
          type: 'SELECT',
          label: '单位性质',
          fieldName: 'unitProperty',
          placeholder: '请选择',
          itemList: this.createDictList('7029')
        },
        {
          type: 'SELECT',
          label: '行业类型',
          fieldName: 'industryType',
          placeholder: '请选择',
          itemList: this.createDictList('7030')
        },
        {
          type: 'SELECT',
          label: '客户级别',
          fieldName: 'customerLevel',
          disabled: true,
          placeholder: '请选择',
          itemList: this.createDictList('1519')
        },
        {
          type: 'SELECT',
          label: '婚姻状况',
          fieldName: 'maritalStatus',
          placeholder: '请选择',
          itemList: this.createDictList('7028')
        },
        {
          type: 'SELECT',
          label: '家庭年收入',
          fieldName: 'annualFamilyIncome',
          placeholder: '请选择',
          itemList: this.createDictList('1290')
        },
        {
          type: 'SELECT',
          label: '兴趣爱好',
          fieldName: 'hobby',
          placeholder: '请输入',
          itemList: this.createDictList('9135')
        },
        {
          type: 'SELECT',
          label: '习惯联系方式',
          fieldName: 'contactDetails',
          placeholder: '请选择',
          itemList: this.createDictList('1532')
        },
        {
          type: 'SELECT',
          label: '方便联系时段',
          fieldName: 'convenientContactTime',
          placeholder: '请选择',
          itemList: this.createDictList('9122')
        },
        {
          type: 'INPUT',
          label: '使用人',
          fieldName: 'userName',
          placeholder: '请输入',
          rules: [{ required: true, message: '请输入', trigger: 'blur' }]
        },
        {
          type: 'INPUT',
          label: '使用人电话',
          fieldName: 'userPhone',
          placeholder: '请输入',
          rules: [
            { required: true, message: '请输入', trigger: 'blur' },
            {
              validator: phoneAndSolidify,
              trigger: 'blur'
            }
          ]
        }
        // {
        //   type: 'SELECT',
        //   label: '大客户订单',
        //   fieldName: 'isMajor',
        //   placeholder: '请选择',
        //   rules: [{ required: true, message: '请选择', trigger: 'change' }],
        //   itemList: this.createDictList('1004')
        // }
      ];
    },
    // ----------------------------销售信息--------------------------
    createdFrom2() {
      return [
        {
          type: 'BREAK_SPACE',
          label: '销售信息'
        },
        {
          type: 'SELECT',
          label: '购车用途',
          fieldName: 'buyPurpose',
          placeholder: '请选择',
          itemList: this.createDictList('1511'),
          rules: [{ required: true, message: '请输入', trigger: 'change' }]
        },
        {
          type: 'INPUT',
          label: '销售顾问',
          fieldName: 'salesManName',
          placeholder: '请输入'
        },
        // {
        //   type: 'SELECT',
        //   label: '销售顾问',
        //   fieldName: 'salesManId',
        //   placeholder: '请选择',
        //   itemList: []
        // },
        {
          type: 'INPUT_NUMBER',
          label: '购车价格',
          fieldName: 'buyPrice',
          maxlength: 9,
          placeholder: '请输入',
          rules: [{ required: true, message: '请输入', trigger: 'blur' }]
        },
        {
          type: 'SELECT',
          label: '支付方式',
          fieldName: 'payType',
          placeholder: '请选择',
          itemList: this.createDictList('6015'),
          rules: [{ required: true, message: '请输入', trigger: 'change' }],
          change: val => {
            if (val) {
              this.showItems2(val);
            }
          }
        },
        {
          type: 'SELECT',
          label: '金融机构',
          fieldName: 'financialInstitution',
          placeholder: '请选择',
          itemList: this.createDictList('9602'),
          hidden: true
        },
        {
          type: 'SELECT',
          label: '期数',
          fieldName: 'periodsNumber',
          placeholder: '请选择',
          itemList: this.createDictList('6061'),
          hidden: true
        },
        {
          type: 'DATE',
          label: '交车日期',
          fieldName: 'deliveryDate',
          dateType: 'exactdate',
          disabled: true,
          placeholder: '请选择',
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'DATE',
          label: '开票日期',
          fieldName: 'invoiceDate',
          dateType: 'exactdate',
          placeholder: '请选择',
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'INPUT',
          label: '发票号',
          fieldName: 'invoiceNo',
          placeholder: '请输入',
          rules: [
            { required: true, message: '请输入', trigger: 'blur' },
            { trigger: 'blur', validator: banWord }
          ]
        },
        {
          type: 'INPUT_NUMBER',
          label: '开票金额',
          fieldName: 'invoiceAmount',
          maxlength: 9,
          placeholder: '请输入',
          rules: [
            { required: true, message: '请输入', trigger: 'blur' },
            {
              validator: function(rule, value, callback) {
                if (value === undefined || value === '' || value === null) {
                  callback();
                }
                var g = /^\d+$|^\d*\.\d+$/g;
                if (!g.test(value)) {
                  callback(new Error('只能输入数字'));
                }
                callback();
              },
              trigger: 'blur'
            }
          ]
        },

        // {
        //   type: 'SELECT',
        //   label: '特殊订单',
        //   fieldName: 'isSpecial',
        //   itemList: this.createDictList('1004'),
        //   rules: [{ required: true, message: '请选择', trigger: 'change' }]
        // },
        {
          type: 'INPUT',
          label: '车牌号',
          fieldName: 'plateNumber',
          placeholder: '请输入'
        },
        {
          type: 'DATE',
          label: '上牌日期',
          fieldName: 'plateDate',
          dateType: 'exactdate',
          placeholder: '请选择'
        },
        {
          type: 'INPUT',
          label: '行驶证号',
          fieldName: 'drivingNo',
          placeholder: '请输入',
          rules: [{ trigger: 'blur', validator: banWord }]
        },
        {
          type: 'DATE',
          label: '行驶证注册日期',
          fieldName: 'drivingRegisteDate',
          dateType: 'exactdate',
          placeholder: '请选择'
        },
        {
          type: 'SELECT',
          label: '是否三包',
          fieldName: 'isThreeGuarantees',
          placeholder: '请选择',
          itemList: this.createDictList('1004'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'SELECT',
          label: '是否异地购车',
          fieldName: 'isOffsite',
          placeholder: '请选择',
          itemList: this.createDictList('1004'),
          rules: [{ required: true, message: '请选择', trigger: 'change' }]
        },
        {
          type: 'SELECT',
          label: '是否二次购买',
          fieldName: 'isSecond',
          placeholder: '请选择',
          itemList: this.createDictList('1004')
        },
        {
          type: 'SELECT',
          label: '是否建设电桩',
          fieldName: 'isBuild',
          placeholder: '请选择',
          itemList: this.createDictList('1004')
        },
        {
          type: 'SELECT',
          label: '是否申报补贴',
          fieldName: 'isSubsidy',
          placeholder: '请选择',
          itemList: this.createDictList('1004')
        },
        {
          type: 'SELECT',
          label: '上牌省份',
          fieldName: 'plateProvince',
          placeholder: '请选择',
          itemList: this.createRegionsList(),
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          change: p => {
            if (p) {
              this.formList2.find(x => {
                if (x.fieldName == 'plateCity') {
                  x.initialValue = '';
                  x.itemList = this.createcityList(p);
                }
              });
            } else {
              this.formList2.find(x => {
                if (x.fieldName == 'plateCity') {
                  x.initialValue = '';
                  x.itemList = [];
                }
              });
            }
          }
        },
        {
          type: 'SELECT',
          label: '上牌城市',
          fieldName: 'plateCity',
          placeholder: '请选择',
          rules: [{ required: true, message: '请选择', trigger: 'change' }],
          itemList: []
        },
        {
          type: 'SELECT',
          label: '车辆性质',
          fieldName: 'vehicleType',
          placeholder: '请选择',
          itemList: this.createDictList('4103')
        },
        {
          type: 'INPUT_NUMBER',
          label: '交车里程',
          maxlength: 9,
          fieldName: 'deliveryMileage',
          placeholder: '',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '核销码',
          fieldName: 'checkNo',
          placeholder: '请输入'
        },
        {
          type: 'UPLOAD_FILE',
          label: '发票附件',
          fieldName: 'invoiceUrls',
          rules: [{ required: false, message: '请上传', trigger: 'change' }],
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg'],
            fileSize: 1,
            max: 1024,
            limit: 1,
            tipText: '最多上传1个附件'
          }
        },
        // ----------------------------其他信息--------------------------

        {
          type: 'BREAK_SPACE',
          label: '其他信息'
        },
        {
          type: 'TEXT_AREA',
          label: '备注',
          fieldName: 'remark',
          placeholder: '请输入',
          selfCols: 3
        },
        {
          type: 'UPLOAD_FILE',
          label: '其他附件',
          fieldName: 'otherUrls',
          upload: {
            actionUrl: '/api/file/oss/upload',
            fileTypes: ['jpg', 'png', 'pdf'],
            limit: 1,
            tipText: '最多上传1个附件'
          }
        }
      ];
    }
  }
};
</script>
